<?php
namespace app\applet\controller;
use think\Db;
use think\Controller;
use think\Log;
use app\service\applet\zaozaoService;
use app\service\billService;
use app\service\xcxService;
use app\service\appletRoomService;
class Zaozao extends Controller{
    
    //获取支付宝用户的user_id
    public function userId()
    {
        $api = new zaozaoService();
        //获取当前车辆支付宝ID
        $code = request()->get('auth_code');
        $oauthtoken = $api->xcxoauthToken($code);
       
        if(property_exists($oauthtoken,'sub_msg')){
            return json(['info' => $oauthtoken->sub_msg]);
        }
        $user_id = $oauthtoken->user_id;//user_id
        return json(['info' => $user_id]);
        return json_encode($user_id);
    }

    //小区列表
    public function  communityname(){
        $serviceid=6;
        if(isset($_GET['communityname'])){
            $communityname = $_GET['communityname'];
            //$li = (new appletRoomService())->communityName($communityname,$serviceid);
            $li = (new appletRoomService())->communityNameAll($communityname);
            foreach ($li as $l){
                $lis['adcode'] = $l['community_id'];
                $lis['address'] = $l['community_address'];
                $lis['city'] = $l['community_name'];
                $list[] = $lis;
            }
        }else{
            //$li = (new appletRoomService())->communityList($serviceid);
            $li = (new appletRoomService())->communityListAll();
            //echo "<pre>";
            //var_dump($li);die;
            foreach ($li as $l){
                $lis['adcode'] = $l['community_id'];
                $lis['address'] = $l['community_address'];
                $lis['city'] = $l['community_name'];
                $list[] = $lis;
            }
        }
        if(empty($list)){
            return json_encode($li);
        }else{
            return json_encode($list);
        }
    }

    public function getimg(){
        $imglist=Db::table("applet_carousel")->where("service_id",0)->select();
        return json_encode($imglist);
    }



    
} 